The Picture Game

Generating a random picture. (it may take a few seconds).





Discussion

The JavaScript Cookbook Picture Generator builds pictures out of small black and white icons laid out in sequence. This script sets the color variable to "BLACK" initially. During the script, it randomly toggles back and forth. A carriage return follows each row using the break-line directive.

<SCRIPT>
var color="BLACK"
for (var tmpj = 0; tmpj < 12; tmpj++)
{
    for (var tmpi = 0; tmpi < 12; tmpi++)
    {
        color = (random(2) == 1) ? "WHITE" : "BLACK"
        document.write(">img src=\"../GRAFX/"+color+".GIF\""+
            "HEIGHT= 16 WIDTH=16>")
    }
    document.write("<br>")
}
</SCRIPT>
Copyright ©2000 by Charles River Media, All Rights Reserved